﻿Imports System.Data.OleDb

Public Class soup_and_stew
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdcontent.Click

        If fileuploadpics.HasFile Then
            Dim piclocationonserverhardisk = Request.MapPath("pictures") & "/" & fileuploadpics.FileName
            fileuploadpics.SaveAs(piclocationonserverhardisk)
        End If

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Dim SqlString As String = "Insert into soup(soupname,Ingredients,Preparation,Picture) Values (@f1,@f2,@f3,@f4)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", txtsoupname.Text)
        cmd.Parameters.AddWithValue("@f2", txtingredients.Text)
        cmd.Parameters.AddWithValue("@f3", txtpreparation.Text)
        cmd.Parameters.AddWithValue("@f4", "pictures/" & fileuploadpics.FileName)

        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("confirmation.aspx")

    End Sub
End Class